﻿using UnityEditor;
using UnityEngine;

namespace Yoozoo.Gta.ProjBuilder.Editor
{
    [CustomEditor(typeof(SubPackageCollector))]
    public class SubPackageCollectorEditor : UnityEditor.Editor
    {
        private SubPackageCollector m_Target;

        void OnEnable()
        {
            m_Target = target as SubPackageCollector;
        }

        void OnDisable()
        {
            m_Target = null;
        }

        public override void OnInspectorGUI()
        {
            GUILayout.Label("有问题点击↗的?按钮查看文档", GUILayout.Height(20));

            var oldColor = GUI.color;
            GUI.color = Color.red;
            if (GUILayout.Button("先点我打包图集!!!", GUILayout.Height(40)))
            {
                EditorApplication.ExecuteMenuItem("Tools/Build/Atlas Pack");
            }

            GUI.color = oldColor;
            base.OnInspectorGUI();

            if (GUILayout.Button("刷新收集", GUILayout.Height(40)))
            {
                if (m_Target != null)
                {
                    Managers.ResourceManagerV2.Editor.ResourceTools.EditorResourceSettings.AssetPackTags.Add(m_Target.Tag);
                    var collection = new Managers.ResourceManagerV2.Editor.ResourceTools.AssetPackListCollection();
                    collection.Load();
                    collection.Save(m_Target.Tag);
                }
            }
        }
    }
}
